﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BusinessLogicLayer
{
    public class ActionResultAsList<T>
    {
        public List<Exception> Exceptions { get; set; }
        public bool Success
        {
            get { return !Exceptions.Any(); }
        }
        public List<T> ObjectList { get; set; }

        public ActionResultAsList()
        {
            Exceptions = new List<Exception>();
            ObjectList = new List<T>();
        }

        public void AddException(Exception ex)
        {
            Exceptions.Add(ex);
        }

        public override string ToString()
        {
            string s = "";
            foreach (Exception ex in Exceptions)
            {
                s += ex.Message + "\n";
            }
            return s;
        }
    }
}
